package com.leecode;

/**
 * @Author: huangzhigao
 * @Date: 2022/3/28 22:16
 */
public class leecode303 {
    public class NumArray {
        private int[] sum;

        public NumArray(int[] nums) {
            sum = new int[nums.length + 1];
            for (int i = 0; i < nums.length; i++) {
                sum[i + 1] = sum[i] + nums[i];
            }
        }

        public int sumRange(int left, int right) {
            return sum[right+1] - sum[left];
        }
    }

}
